Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Objects /
Chapter 5 - Ink Objects / Using Ink Objects


Getting and Setting an Ink Object's Color

You can use the GXGetInkColor function to retrieve the color (as a gxColor
structure) of an existing ink object; you can use the GXGetShapeColor function to retrieve the color of the ink object associated with a particular shape. You can use
the GXSetInkColor function to assign a color to an ink; you can use the GXSetShapeColor function to assign a color to the ink object associated with a particular shape.

To simply get the color of an existing ink (referenced here by myInk) requires defining a color structure, then calling the GXGetInkColor function to fill it:

gxColor myInkColor;
GXGetInkColor(myInk, &myInkColor);
If you want to obtain some part of the ink's color structure, such as its color space, you could make calls like this:

gxColorSpace myInkSpace;
gxColor myInkColor;
myInkSpace = GXGetInkColor(myInk, &myInkColor)->space;
Conversely, to assign some portion of an ink's color structure, such as its color profile (here called newProfile), you could make these calls:

gxColor myInkColor;
GXGetInkColor(myInk, &myInkColor);
myInkColor.profile = newProfile;
GXSetInkColor(myInk, &myInkColor);
You can give a shape a specific color by setting the individual values of its ink's color components. For a shape (myShape) whose ink uses an RGB color space, you could do something like this (with numeric color values newRed, newBlue, and newGreen):

gxColor newColor;
newColor.space = gxRGBSpace;
newColor.profile = nil;
newColor.element.rgb.red = newRed;
newColor.element.rgb.green = newGreen;
newColor.element.rgb.blue = newBlue;
GXSetShapeColor(myShape, &newColor);
The GXGetInkColor function is described on page 5-68; the GXGetShapeColor function is described on page 5-70. The GXSetInkColor function is described on page 5-69; the GXSetShapeColor function is described on page 5-71.

Colors and how to program with them are not described further in this chapter; for complete information, see the chapter "Colors and Color-Related Objects" in this book.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996